<template>
<!--公司账务统计 and  支付收款方式-->
  <div>
    <div class="company-account-box">
        <div style="display: flex;padding-left: 15px;padding-top: 11px;height: 30px" >
          <a  href="#">
            <div style="display: flex"  >
              <i class="icon-duojizhangbuyuechaxun" style="margin-top: 6px;margin-right: 5px;margin-left: 5px"></i>
              <h3>公司账务余额(支付收款方式)</h3>
            </div>
          </a>
        </div>
      <div class="company-account-box-detail">
        <el-card v-for="(item,index) in dataList" :key="index" class="box-card">
          <div slot="header" class="clearfix" >
            <span style="font-weight: bold">{{item.pay_take_name}}</span>
            <el-button style="float: right; padding: 3px 0" type="text" @click="openDetail(item.all_company_money_id)" >查看明细</el-button>
            <span style="float: right;margin-right: 90px;font-weight: lighter">余额:&nbsp;<span style="font-style: oblique;color: #ff3526">{{item.money}}<span style="color: #2c3e50">元</span></span></span>
          </div>
          <div>
            <img v-if="item.pay_take_id===1" src="../../assets/wechat.png" style="width: 450px;height: 180px" class="image">
            <img v-if="item.pay_take_id===2" src="../../assets/alipay.png" style="width: 450px;height: 180px" class="image">
            <img v-if="item.pay_take_id===4" src="../../assets/backpay.png" style="width: 450px;height: 180px" class="image">
            <img v-if="item.pay_take_id===5" src="../../assets/check.png" style="width: 450px;height: 180px" class="image">
              <div v-if="item.pay_take_id===3" style="background-color: #f2f2f2;width: 450px;height: 180px">
                  <h1   style="font-size: 80px;text-align: center;padding-top: 30px">现金支付</h1>
              </div>
            <div v-if="item.pay_take_id!==1 && item.pay_take_id!==2 && item.pay_take_id!==3 && item.pay_take_id!==4 && item.pay_take_id!==5" style="background-color: #f2f2f2;width: 450px;height: 180px">
              <h1   style="font-size: 80px;text-align: center;padding-top: 30px">现金支付</h1>
            </div>
          </div>
        </el-card>

      </div>


      <el-dialog
        title="余额收入支出情况"
        :visible.sync="dialogVisible"
        width="60%"
        >


        <el-table
          v-loading="loading"
          element-loading-text="已经很努力加载了(•́へ•́╬)"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
          :data="detailDataList"
          border
          height="392"
          style="width: 100%">

          <el-table-column
            align="center"
            prop="account_time"
            label="日期"
            width="120">
          </el-table-column>
          <el-table-column
            align="center"
            prop="small_account_name"
            label="类型"
            width="200">
          </el-table-column>
          <el-table-column
            align="center"
            prop="who"
            label="对象"
            width="240">
          </el-table-column>
          <el-table-column
            align="center"

            label="金额"
            width="200">
            <template slot-scope="scope">

              <span v-if="scope.row.is_pay_or_take===1" style="font-size: 16px;font-weight: bold;color: #ff3526">-{{scope.row.money}}元</span>
              <span v-if="scope.row.is_pay_or_take===2" style="font-size: 16px;font-weight: bold;">{{scope.row.money}}元</span>

            </template>
          </el-table-column>
          <el-table-column

            fixed="right"
            label="操作"
            width="100">
            <template slot-scope="scope">
              <el-button  type="text" size="small">查看</el-button>
              <el-button type="text" size="small">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div>
          <el-pagination
            align="center"
            style="margin-top: 10px"
            background
            layout="prev, pager, next"
            @current-change="changePage"
            :page-size="pageSize"
            :current-page="currentPage"
            :total="total">
          </el-pagination>
        </div>
      </el-dialog>

    </div>
  </div>
</template>

<script>
import {get, post} from "../../utils/request";
import {COMPANY_ACCOUNT_SIZE} from "../../utils/basic-data";

export default {
  name: "CompanyAccount",
  data(){
    return{
      loading:false,
      dialogVisible:false,
      dataList:[],
      imgUrl:null,
      total:0,
      pageSize:COMPANY_ACCOUNT_SIZE,
      currentPage:1,
      nowPayWay:null,
      detailDataList:[]

    }
  },
  mounted() {
    get('/api/v1/companymoney/all').then(resp=>{
      this.dataList=resp.data
    })
  },
  methods:{
    changePage(value){
      this.loading=true
      this.currentPage=value
      get('/api/v1/companymoney/detail',{allCompanyMoneyId:this.nowPayWay,currentPage:this.currentPage,pageSize:this.pageSize}).then(resp=>{
        this.currentPage=resp.data.currenPage
        this.total=resp.data.total
        this.detailDataList=resp.data.objectList
        this.loading=false
      })
    },
    openDetail(item){
      this.nowPayWay=item
      this.dialogVisible=true
      this.total=0
      this.currentPage=1
      this.detailDataList=[]
      this.loading=true
      get('/api/v1/companymoney/detail',{allCompanyMoneyId:item,currentPage:this.currentPage,pageSize:this.pageSize}).then(resp=>{
        this.currentPage=resp.data.currenPage
        this.total=resp.data.total
        this.detailDataList=resp.data.objectList
        this.loading=false
      })


    }
  }
}
</script>

<style scoped>
h1{
  margin: 0;
}

.company-account-box-detail{
  width: 100%;
  border-top: 1px solid #c2c0c0;
  border-bottom: 1px solid #c2c0c0;
  height: 605px;
  overflow: hidden;
  overflow-y: scroll;
  display: flex;
  flex-wrap: wrap;
  /*background-color: #f2f2f2;*/
  /*background-color: #409EFF;*/
}
a{
  text-decoration: none;
  color: #2c3e50;
}
h3{
  margin: 0;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both
}
.box-card {
  width: 480px;
  height: 280px;
  margin-left: 90px;
  margin-top: 10px;
  margin-right:  10px;
  margin-bottom: 5px;
  /*margin-bottom: 20px;*/
}
.company-account-box{
  height: 674px;

  margin-top: 10px;
  width: 1290px;
  background-color: white;
  border-radius: 30px;
  box-shadow:  20px 20px 60px #bebebe,
  -20px -20px 60px #ffffff;
}

</style>
